/* GUI CONVERTED from reworp04.p (converter v1.75) Thu Oct  5 12:01:22 2000 */
/* reworp04.p - REPETITIVE DISPATCH LIST                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/*F0PN*/ /*V8:ConvertMode=FullGUIReport                                     */
/* REVISION: 7.3     LAST MODIFIED: 02/11/93    BY: emb *G676*              */
/* REVISION: 7.3     LAST MODIFIED: 04/14/93    BY: ram *G952*              */
/* REVISION: 7.3     LAST MODIFIED: 03/30/94    BY: WUG *GJ25*              */
/* REVISION: 7.3     LAST MODIFIED: 09/01/94    BY: ljm *FQ67*              */
/* REVISION: 8.6     LAST MODIFIED: 10/14/97    BY: GYK *K0YX*              */
/* REVISION: 8.6E    LAST MODIFIED: 02/23/98    BY: *L007* A. Rahane        */
/* REVISION: 8.6E    LAST MODIFIED: 10/04/98    BY: *J314* Alfred Tan       */
/* REVISION: 9.1     LAST MODIFIED: 03/24/00    BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1     LAST MODIFIED: 08/12/00    BY: *N0KP* myb              */
/* REVISION: 9.1     LAST MODIFIED: 09/11/00    BY: *N0RQ* Mudit Mehta      */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*K0YX*/ {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reworp04_p_1 "Page Break on Work Center"
/* MaxLen: Comment: */

&SCOPED-DEFINE reworp04_p_2 "Qty Open"
/* MaxLen: Comment: */

&SCOPED-DEFINE reworp04_p_3 "Window Days"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*K0YX*/ define variable cutoff as date.
/*K0YX*/ define variable i as integer.
/*K0YX*/ define variable mch like wr_mch.
/*K0YX*/ define variable mch1 like wr_mch.
/*K0YX*/ define variable open_ref like wo_qty_ord label {&reworp04_p_2} no-undo.
/*K0YX*/ define variable runtime like wr_run no-undo.
/*K0YX*/ define variable setup like wr_setup no-undo.
/*K0YX*/ define variable site like si_site.
/*K0YX*/ define variable site1 like si_site.
/*K0YX*/ define variable skpage like mfc_logical initial yes
                                            label {&reworp04_p_1}.
/*FQ67* /*K0YX*/ define variable window as integer
                                            label "Window Days" initial 3. */
/*FQ67*/ /*K0YX*/ define variable wndw as integer
                                               label {&reworp04_p_3} initial 3.
/*K0YX*/ define variable wkctr like wr_wkctr.
/*K0YX*/ define variable wkctr1 like wr_wkctr.

         {mfdatev.i}

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
site           colon 30
            site1          label {t001.i} colon 49
            wkctr          colon 30
            wkctr1         label {t001.i} colon 49
            mch            colon 30
            mch1           label {t001.i} colon 49 skip  (1)
/*FQ67*     window         colon 30 */
/*FQ67*/    wndw           colon 30
            skpage         colon 30 skip
          SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         FORM /*GUI*/ 
            si_site
            wc_wkctr
            wc_mch
            wc_desc        no-label
         with STREAM-IO /*GUI*/  frame b side-labels page-top width 132 no-attr-space.

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame b:handle).

         site = global_site.
         site1 = global_site.

/*K0YX*/ {wbrp01.i}

         
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


            if mch1 = hi_char then mch1 = "".
            if wkctr1 = hi_char then wkctr1 = "".
            if site1 = hi_char then site1 = "".

/*K0YX*/    if c-application-mode <> 'web' then
            
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


/*K0YX*/    {wbrp06.i &command = update
                      &fields = " site site1 wkctr wkctr1 mch mch1 wndw skpage"
                      &frm = "a"}

/*K0YX*/    if (c-application-mode <> 'web') or
/*K0YX*/       (c-application-mode = 'web' and
/*K0YX*/       (c-web-request begins 'data'))
            then do:

               bcdparm = "".
               {mfquoter.i site   }
               {mfquoter.i site1  }
               {mfquoter.i wkctr  }
               {mfquoter.i wkctr1 }
               {mfquoter.i mch    }
               {mfquoter.i mch1   }
/*FQ67*        {mfquoter.i window } */
/*FQ67*/       {mfquoter.i wndw }
               {mfquoter.i skpage }

               if wkctr1 = "" then wkctr1 = hi_char.
               if mch1 = "" then mch1 = hi_char.
               if site1 = "" then site1 = hi_char.

/*K0YX*/    end.

            
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



            {mfphead.i}

            for each si_mstr no-lock
            where si_site >= site and si_site <= site1:

               cutoff = ?.
               know_date = today.
/*FQ67*        {mfdate.i know_date cutoff window si_site} */
/*FQ67*/       {mfdate.i know_date cutoff wndw si_site}

               for each wc_mstr no-lock
               where wc_wkctr >= wkctr and wc_wkctr <= wkctr1
               and wc_mch >= mch and wc_mch <= mch1,
               each wr_route no-lock
               where wr_wkctr = wc_wkctr and wr_mch = wc_mch
               and
               (index("qhsr",wr_status) > 0
               or
               (wr_start <= cutoff and wr_status <> "C")),
               each wo_mstr no-lock
               where wo_lot = wr_lot
               and (wo_status = "R" or wo_type = "S")
               and wo_site = si_site
               and wo_status <> "C"
               and wo_type <> "C"
/*N0RQ*        break by wr_wkctr by wr_mch by wr_start by wr_due by wr_part
 *             by wr_op: */
/*N0RQ*/       break by wr_wkctr by wr_mch by wr_start by wr_due by wr_part
               by wr_op with frame f-a:

                  FORM /*GUI*/ 
                     wr_start
                     wr_due
                     wr_part
                     pt_desc1
                     wr_op
                     wo_type
                     wr_lot
                     open_ref
                     setup
                     runtime
                     wr_status
/*N0RQ*           with width 132. */
/*N0RQ*/          with STREAM-IO /*GUI*/  frame f-a width 132.

                  /* SET EXTERNAL LABELS */
/*N0RQ*/          setFrameLabels(frame f-a:handle).

                  find pt_mstr where pt_part = wr_part no-lock.

                  if first-of(wr_mch) then do:
/*K0YX*              disp  */
/*K0YX*/             display
                        si_site wc_wkctr wc_mch wc_desc
                     with frame b STREAM-IO /*GUI*/ .
                  end.

                  open_ref = max(wr_qty_ord - max (wr_qty_comp,0)
                             - max (wr_qty_rjct,0),0).
                  setup = 0.

                  if wr_status <> "C" and open_ref <> 0 and wr_act_run = 0
                  then
                     setup = wr_setup.

                  runtime = open_ref * wr_run.
/*K0YX*           disp */
/*K0YX*/          display
                     wr_part
                     pt_desc1
                     wr_start
                     wr_due
                     wo_type
                     wr_lot
                     wr_op
                     open_ref
                     setup
                     runtime
                     wr_status WITH STREAM-IO /*GUI*/ .

                  down 1.

/*K0YX*           disp  */
/*K0YX*/          display pt_desc2 @ pt_desc1 WITH STREAM-IO /*GUI*/ .

                  if page-size - line-counter < 2 then page.

                  if last-of(wr_mch) then do:
                     hide frame b.
                     if skpage then page.
                  end.

                  
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


               end.

            end.

            hide frame b.
            
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


         end.

/*K0YX*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds="   site site1 wkctr wkctr1 mch mch1 wndw skpage "} /*Drive the Report*/
